#include <iostream>
#define N 100

using namespace std;


void asc_sort(int array[], int elements){
int i, j, aux;
for(i=0; i<elements; ++i){
    aux=array[i];
    j=i-1;
    while (aux<array[j] && j>=0){
        array[j+1]=array[j];
			--j;}
		array[j+1]=aux;}
}

void readVector(int array[], int elements){
for (int i=0; i<elements; i++){
	cout<<"a["<<i<<"]=";
	cin>>array[i];
	cout<<"\n";}
}


int main(){
int array[N];
int elements;
int k;
int i;
int number;
cout<<"Type the number of elements you want in the array: ";
cin>>elements;
readVector(array,elements);

cout<<"Type which element(in ascending order) do you want: ";
cin>>k;

cout<<"The original array is ";
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
cout<<endl;

asc_sort( array, elements);
for(i=0;i<elements;i++){
number=array[k-1];}
cout<<"Element on position "<<k<<" in ascending order is: "<<number<<endl;

return 0;
}


